# How to install Devuan without GUI installer

_**Note:** This is still under testing. So things might not be correct. It may also break/damage your system. Do NOT use this guide on your production/stable machine. Keep away if you want your system to stay safe._

GUI installer is helpful for new users. But sometimes control is needed over the install process, so installation has to be made without the installer. This method works for any Debian based distro, not only Devuan. This is a step by step method that resembles the Arch Linux install process. So you have better control over everything.

Note that this has to be run from an existing Devuan/Debian installation. For other distros, you'll have to install debootstrap from .deb through `binutil`'s `ar` tool.

Run this from a working live image. I have tried this with Ascii 2.1 Xfce desktop-live image (`devuan_ascii_2.1_amd64_desktop-live.iso`).


Mount the root filesystem:

```
mount /dev/sdxY /mnt
```

_`x` stands for the drive letter, `Y` stands for the number. You can use any device, even VG-LVMs. In that case `/dev/mapper/volumegroupname-lvmname` can be used._

If you want a separate partition for something (e.g. /boot, /home) you'll have to mount them:

```
mkdir -p /mnt/boot
mount /dev/sdxY /mnt/boot
...
mkdir -p /mnt/home
mount /dev/sdxY /mnt/home
```


Now install the packages with debootstrap:

```
debootstrap --arch amd64 ascii /mnt http://deb.devuan.org/merged
```

Here,
- `amd64`: You can use any other architecture that your distro supports, such as `i386`.
- `ascii`: Codename for the version you want. [Details](https://devuan.org/os/releases)
- `/mnt`: Your mount point.
- `http://deb.devuan.org/merged`: Devuan packages [url](http://pkgmaster.devuan.org/mirror_list.txt). Check a [typical](https://devuan.org/os/packages) `/etc/apt/sources.list` for this.


If you don't have debootstrap for some reason, you can probably install it: `apt install debootstrap`


The base system should be installed. Now use the `debchroot.sh` in the same directory as this file so that you don't have to type all the `mount` and `cp` commands below. Just run:
```
/path/to/debchroot.sh /mnt
```

Otherwise, run these below:

```
mount -o bind /dev /mnt/dev
mount -o bind /proc /mnt/proc
cp /etc/mtab /mnt/etc/mtab
cp /etc/network/interfaces /mnt/etc/network/interfaces
chroot /mnt /bin/bash
```


Add your filesystems into the /etc/fstab:

```
echo '/dev/sdxY / ext4 defaults 0 1' >> /etc/fstab
echo '/dev/sdxY /boot ext2 defaults 0 2' >> /etc/fstab
```

_Change the command appropriately for your filesystem. e.g. device path, ext4 etc. Be careful not to use single angle bracket `>`. It will replace existing content. For filesystem identifiers, ideally you should use UUIDs._


Run the updates if any remaining packages need updating:

```
apt update
apt upgrade
```

Setup locales:

```
apt install locales
dpkg-reconfigure locales
```

Install grub:

```
apt install grub-pc
```

_This may ask you to install grub on a device. I choose `/dev/sdx`. Choose hitting the spacebar._

If install fails, run it manually:

```
grub-install /dev/sdx
```


---

**/\* Encryption Notes:**

If you're using LUKS, add: `GRUB_ENABLE_CRYPTODISK=y` in `/etc/default/grub`

```
echo 'GRUB_ENABLE_CRYPTODISK=y'>> /etc/default/grub
```


If you are using an Encrypted LUKS VG, LVM etc. it is a good idea to list them in /etc/crypttab. In case of VG, run `lsblk /dev/sdx -o name,uuid`.

```
vgname  /dev/sdxY  none  luks,initramfs
```
or
```
vgname  UUID=<UUID here>  none  luks,initramfs
```

- `vgname`: Your volume group name on the lsblk's first column.
- `/dev/sdxY`: The device that has the volume group.
- `none`: Indicates you have no key to be passed here. You can enter your cryptsetup key file here if you have one. You may have to use `passdev` script, so that it can unlock and read the file.
- `luks,initramfs`: Indicates that it is a LUKS volume and it has to be initialized in the initram stage (since we will be booting onto it).

Example with passdev:
```
vgname  UUID=<UUID here>  /dev/disk/by-uuid/<UUID of filesystem which has key>:/path/to/keyfile  luks,initramfs,keyscript=/lib/cryptsetup/scripts/passdev
```

To create keyfile:
```
dd if=/dev/urandom of=/boot/keyfile bs=1024 count=4
chmod 0400 /boot/keyfile
cryptsetup -v luksAddKey /dev/disk/by-uuid/<UUID of filesystem above the luks VG> /boot/keyfile
```


Also install packages to handle encryption:

```
apt install lvm2 cryptsetup
```

**\*/**

---

Install a kernel. To check which versions are available:

```
apt search linux-image
```


Select a version from the list. Example:

```
apt install linux-image-amd64
```


Set root password:

```
passwd
```


To create a new user:

```
useradd -m -g users -G sudo,cdrom,floppy,audio,video,dip,disk,www-data,plugdev,netdev,lpadmin,scanner -s /bin/bash yourusername
passwd yourusername
apt install sudo
```


You may also want to do `apt install network-manager` for internet connectivity.


Set the hostname and add to hosts file:

```
MYHOST="<hostname>"
echo $MYHOST>/etc/hostname
echo "127.0.0.1 $MYHOST">>/etc/hosts  # notice the double angle brackets
```


To install a desktop now (automatic):

```
tasksel --new-install
```

Or manually (needs more involvement and customization):

```
apt install xserver-xorg xinit
# install a DM of your choice
apt install lxdm # or slim, lightdm etc.
update-rc.d lxdm enable # to let it appear after boot (maybe enabled by default)
# install a DE of your choice
apt install xfce4
```


Clean unneeded package files:

```
apt clean
```

Exit chroot and unmount:

```
exit
umount -R /mnt
```

Source:
- [Debian User Forums • View topic - Installing Debian without the installer.](http://forums.debian.net/viewtopic.php?f=16&t=76895)
- [HOW-TO: Install Debian using debootstrap.](https://www.linuxquestions.org/questions/debian-26/how-to-install-debian-using-debootstrap-4175465295/)
